package com.tfj.mvp.tfj.detail.sign;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

import com.hyphenate.tfj.R;
import com.tfj.mvp.base.BaseActivity;
import com.tfj.utils.AntiShakeUtils;

import java.util.Calendar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Liang_Lu on 2017/12/21.
 *
 * @author HuangQiang
 * @github https://github.com/HuangQiang
 */

public class VSignActivity extends BaseActivity<PSignImpl> implements CSign.IVSign {


    @BindView(R.id.btn_submit)
    Button btnSubmit;
    @BindView(R.id.textView_time)
    TextView textViewTime;

    @Override
    protected void initView() {
        super.initView();
        setTitleText("报名看房");

    }

    @Override
    public int setContentViewId() {
        return R.layout.activity_sign;
    }

    @Override
    public void createPresenter() {
        mPresenter = new PSignImpl(mContext, this);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.btn_submit,R.id.textView_time})
    public void onViewClicked(View view) {
        if (AntiShakeUtils.isInvalidClick(view)) {
            return;
        }
        switch (view.getId()) {
            case R.id.btn_submit:
                break;
            case R.id.textView_time:
                showDatePickDlg();
                break;
        }
    }

    public void showDatePickDlg() {
        Calendar calendar = Calendar.getInstance();
        DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                textViewTime.setTextColor(getResources().getColor(R.color.black));
                textViewTime.setText(year + "-" + monthOfYear + "-" + dayOfMonth);
            }
        }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        datePickerDialog.show();

    }

}
